package com.globefrog.example.consumer;

import static org.dbunit.operation.DatabaseOperation.CLEAN_INSERT;
import static org.dbunit.operation.DatabaseOperation.CLOSE_CONNECTION;
import static org.dbunit.operation.DatabaseOperation.DELETE;
import static org.dbunit.operation.DatabaseOperation.DELETE_ALL;
import static org.dbunit.operation.DatabaseOperation.INSERT;
import static org.dbunit.operation.DatabaseOperation.REFRESH;
import static org.dbunit.operation.DatabaseOperation.TRUNCATE_TABLE;
import static org.dbunit.operation.DatabaseOperation.UPDATE;

import com.github.springtestdbunit.operation.DatabaseOperationLookup;
import java.util.HashMap;
import java.util.Map;
import org.dbunit.operation.DatabaseOperation;

/**
 * @author : Globe-Frog
 * @date : Create in 2021/7/12
 */
public class CustomDatabaseOperationLookUp implements DatabaseOperationLookup {


  private static final
      Map<com.github.springtestdbunit.annotation.DatabaseOperation, DatabaseOperation> LOOKUP;

  static {
    LOOKUP = new HashMap<>();
    LOOKUP.put(com.github.springtestdbunit.annotation.DatabaseOperation.UPDATE,
        CLOSE_CONNECTION(UPDATE));
    LOOKUP.put(com.github.springtestdbunit.annotation.DatabaseOperation.INSERT,
        CLOSE_CONNECTION(INSERT));
    LOOKUP.put(com.github.springtestdbunit.annotation.DatabaseOperation.REFRESH,
        CLOSE_CONNECTION(REFRESH));
    LOOKUP.put(com.github.springtestdbunit.annotation.DatabaseOperation.DELETE,
        CLOSE_CONNECTION(DELETE));
    LOOKUP.put(com.github.springtestdbunit.annotation.DatabaseOperation.DELETE_ALL,
        CLOSE_CONNECTION(DELETE_ALL));
    LOOKUP.put(com.github.springtestdbunit.annotation.DatabaseOperation.TRUNCATE_TABLE,
        CLOSE_CONNECTION(TRUNCATE_TABLE));
    LOOKUP.put(com.github.springtestdbunit.annotation.DatabaseOperation.CLEAN_INSERT,
        CLOSE_CONNECTION(CLEAN_INSERT));
  }

  public org.dbunit.operation.DatabaseOperation get(
      com.github.springtestdbunit.annotation.DatabaseOperation operation) {
    return LOOKUP.get(operation);
  }
}
